import request from '@/utils/request'

const api_prefix = '/admin/system/sysMenu'

export default {

  /**
   * 查看某个角色的权限列表
   *
   * @param roleId
   * @returns {*}
   */
  toAssign(id) {
    return request({
      url: `${api_prefix}/toAssign`,
      method: 'get',
      params: id
    })
  },

  /**
   * 给某个角色授权
   *
   * @param assginMenuVo
   * @returns {*}
   */
  doAssign(assignMenuVo) {
    return request({
      url: `${api_prefix}/doAssign`,
      method: 'post',
      data: assignMenuVo
    })
  },

  /**
   *  创建菜单
   * @param sysMenuAddRequest
   * @returns {*}
   */
  addMenu(sysMenuAddRequest) {
    return request({
      url: `${api_prefix}/add`,
      method: 'post',
      data: sysMenuAddRequest
    })
  },

  /**
   * 删除菜单
   *
   * @param deleteRequest
   * @returns {*}
   */
  deleteMenu(deleteRequest) {
    return request(({
      url: `${api_prefix}/delete`,
      method: 'post',
      data: deleteRequest
    }))
  },

  /**
   * 更新菜单
   *
   * @param sysMenuUpdateRequest
   * @returns {*}
   */
  updateMenu(sysMenuUpdateRequest) {
    return request(({
      url: `${api_prefix}/update`,
      method: 'post',
      data: sysMenuUpdateRequest
    }))
  },

  /**
   * 根据 id 获取菜单
   *
   * @param id
   * @returns {*}
   */
  getMenuById(id) {
    return request(({
      url: `${api_prefix}/get`,
      method: 'get',
      params: { id }
    }))
  },

  /**
   * 获取菜单列表
   *
   * @returns {*}
   */
  listMenu() {
    return request(({
      url: `${api_prefix}/list/nodes`,
      method: 'get'
    }))
  }

}
